// --------------------
// -- TEST FUNCTIONS --
// --------------------
tests.scenarios.Origami = {name: "Origami"};

tests.scenarios.Origami.InitCreatesPaper = function () {
    // given

    // when
    mindgraph.origami.init();

    // then
    var resultObject = new tests.prv.ResultObject();
    var assert = resultObject.createAssert();

    assert(mindgraph.origami.paper !== undefined);

    resultObject.setResultMessage(mindgraph.origami.paper);
    return resultObject;
}

tests.scenarios.Origami.RectIsCreatedForNodeType = function () {
    // given
    mindgraph.origami.init();
    mindgraph.origami.paper.register["rect"] = 0;

    // when
    var result = mindgraph.origami.Model.create({type: mindgraph.theory.types.node});

    // then
    var resultObject = new tests.prv.ResultObject();
    var assert = resultObject.createAssert();

    assert(result !== undefined);
    assert(mindgraph.origami.paper.register["rect"] === 1);

    resultObject.setResultMessage(result);
    return resultObject;
}

tests.scenarios.Origami.PathIsCreatedForEdgeType = function () {
    // given
    mindgraph.origami.init();
    mindgraph.origami.paper.register["path"] = 0;

    // when
    var result = mindgraph.origami.Model.create({type: mindgraph.theory.types.edge});

    // then
    var resultObject = new tests.prv.ResultObject();
    var assert = resultObject.createAssert();

    assert(result !== undefined);
    assert(mindgraph.origami.paper.register["path"] === 1);

    resultObject.setResultMessage(result);
    return resultObject;
}

tests.scenarios.Origami.NoObjectIsCreatedForGarbage = function () {
    // given
    mindgraph.origami.init();

    // when
    var result = mindgraph.origami.Model.create({type: "garb13"});

    // then
    var resultObject = new tests.prv.ResultObject();
    var assert = resultObject.createAssert();

    assert(result === undefined);

    resultObject.setResultMessage(result);
    return resultObject;
}

tests.scenarios.Origami.RectCreationUsesCoordinates = function () {
    // given
    var paper = mindgraph.origami.paper;
    paper.clean();
    var setup = {type: mindgraph.theory.types.node, x: 131, y:84};
    
    // when
    var result = mindgraph.origami.Model.create(setup);

    // then
    var resultObject = new tests.prv.ResultObject();
    var assert = resultObject.createAssert();

    assert(result !== undefined);
    assert(paper.register["rect"] === 1);
    var args = paper.params["rect"];
    assert(args !== undefined);
    assert(args && args[0] === setup.x);
    assert(args && args[1] === setup.y);

    resultObject.setResultMessage(result.params.rect);
    return resultObject;
}

tests.scenarios.Origami.MouseEventIsSetForPaper = function () {
    // given

    // when
    mindgraph.origami.init();

    // then
    var paper = mindgraph.origami.paper;
    var resultObject = new tests.prv.ResultObject();
    var assert = resultObject.createAssert();

    assert(paper.node.onclick !== undefined);
    assert(paper.node.onclick === mindgraph.origami.paperOnClick);

    resultObject.setResultMessage("OK");
    return resultObject;
}
// ---------------------------
// -- END of TEST FUNCTIONS --
// ---------------------------
